<!doctype html>
<html xmlns:th="www.thymeleaf.org">
<meta charset="utf-8">
<head th:replace="index::head"></HEAD>
<BODY>
	<header th:replace="index::#ph"></header>
	<!--      导航        -->
	<div style="padding: 3px 8px">
		<span class="layui-breadcrumb">
			<a href="/">作业论坛首页</a>
		</span>
	</div>
	<!--      用户登录表单        -->
	<DIV class="t" style="MARGIN-TOP: 15px" align="center">
		<form class="layui-form layui-main" style="width: 800px">
			<div class="layui-form-item">
				<label class="layui-form-label">班级：</label>
				<div class="layui-input-block">
					<layselect 
						items="hwctask/task/queryClsSnItems" 
						model="task.clsSn" 
						vf="cls_sn" 
						nf="cls_sn">
					</layselect>
				</div>
			</div>
			<div class="layui-form-item">
				<label class="layui-form-label">标题：</label>
				<div class="layui-input-block">
					<input v-model="task.name" class="layui-input">
				</div>
			</div>
			<div class="layui-form-item">
				<label class="layui-form-label">内容：</label>
				<div class="layui-input-block">
				    <script id="editor" type="text/plain" style="width:100%;height: 100px"></script>
					<textarea id="saytext" style="display: none;"></textarea>	
				</div>			
			</div>
			<div class="layui-form-item">
				<span id="emotion" style="cursor: pointer; margin-right: 10px"><img src="image/face/baiyan.gif" width="20" height="20" alt="" /> 表情</span>
				<button @click="save" type="button" class="layui-btn">提交</button>
				<button onclick="window.history.back();" type="button" class="layui-btn">返回</button>
			</div>
		</form>
		<load v-if="param('cid')" :url="'hwctask/course/get?id=' + param('cid')" data="course"></load>
		<load v-if="param('id')" :url="'hwctask/task/get?id=' + param('id')" data="task"></load>
	</DIV>
	<script type="text/javascript">
	var v = new Vue({
		el : ".t",
		data : { task: {name:"",intro:"",clsSn:""}, course:{}},
		methods : {
			save(){
				let p = usp(this.task);
				p.delete("course");
				p.delete("inUser");
				p.delete("intro");
				p.delete("finishAt");
				p.delete("inTime");
				p.append("intro",ue.val());
				p.append("course.id",this.course.id || this.task.course.id);
				p.append("inUser.id",'[[${session?.loginedUser?.id}]]');
				post("/hwctask/task/save", p,
					res=>{ location.href="to_list?" + (this.course.id || this.task.course.id)}
				);
			}
		}
	})
	layui.element.render();
	</script>
	<!-- 导入页脚 -->
	<footer th:replace="index::footer"></footer>
	<div th:replace="tasklog::ue(v.task.intro)"></div>
</BODY>
</HTML>
